#include <protocol.hpp>
//
#include <connector.hpp>
#include <msg_command_s.hpp>
#include <msg_param_s.hpp>
#include <remote_controller.hpp>
#include <remote_controller_tcp.hpp>
#include <remote_controller_tcp_textlog.hpp>
//
#include <msg_rc_s.hpp>

/* @RegistMainFunction */
int rc_main(int argc, char** argv)
{
	if (argc == 2 && strcmp(argv[1], "tcp_start") == 0)
	{
		Connector::Instance()->Create(RC_TCP_PORT, &RemoteControllerTcp::RemoteControllerTcpCreator);
		Connector::Instance()->Create(RC_TCP_PORT_TEXTLOG, &RemoteControllerTcpTextlog::RemoteControllerTcpTextlogCreator);
		return 0;
	}
	else if (argc == 4 && strcmp(argv[1], "command") == 0)
	{
		msg_command_s cmd;
		memset(&cmd, 0, sizeof(msg_command_s));
		cmd.command	   = strtoul(argv[2], NULL, 0);
		cmd.arg_u32[0] = strtol(argv[3], NULL, 0);
		Connector::Instance()->Send(RC_TCP_PORT, P_TYPE_COMMAND, (char*)&cmd, sizeof(msg_command_s));
		return 0;
	}

	LOGE("Command not found.\n");
	return 0;
}